﻿using System;
using System.Data;
using System.Windows.Forms;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;
using System.IO;
using System.Text;
using System.Net;
using System.Net.Mail;
using System.Timers;

namespace AutoSendMail
{
    public partial class MDIParent : Form
    {
        private log4net.ILog log = log4net.LogManager.GetLogger("ValuesController");

        public MDIParent()
        {
            InitializeComponent();
            Form childForm = new MainForm();
            childForm.MdiParent = this;
            childForm.Show();
            timer1.Start();//开启计时器
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Enabled = true;
            timer.Enabled = false;
            timer.Interval = 60000;//执行间隔时间,单位为毫秒;此时时间间隔为1分钟  
            timer.Start();
            timer.Elapsed += new System.Timers.ElapsedEventHandler(test);
            if (timer.Enabled == true)
            {
                toolStripStatusLabel3.Text = "服务启动！";
            }
            else
            {
                toolStripStatusLabel3.Text = "服务关闭！";
            }
            
        }

        private static void test(object source, ElapsedEventArgs e)
        {
            string Hour = ConfigurationManager.AppSettings["Hour"];
            int A = int.Parse(Hour);
            string Minute = ConfigurationManager.AppSettings["Minute"];
            int B = int.Parse(Minute);
            string Sql = ConfigurationManager.AppSettings["Sql"];
            if (DateTime.Now.Hour == A && DateTime.Now.Minute == B)  //设置时间
                try
                {
                    string strCon = ConfigurationManager.AppSettings["connectionstring"];
                    SqlConnection conn = new SqlConnection(strCon);
                    SqlCommand cmd = new SqlCommand(Sql, conn);
                    //SqlCommand cmd = new SqlCommand("select '100科思股份' as 公司,'1销售订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006') and CONVERT(varchar(10),dcreatesystime,120)<='2019-10-31' union select '100科思股份' as 公司,'1销售订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006') and CONVERT(varchar(10),dcreatesystime,120)=CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'1销售订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006')and CONVERT(varchar(10),dcreatesystime,120)<='2019-10-31' union select '200香港科思' as 公司,'1销售订单' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006') and CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'1销售订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006')and CONVERT(varchar(10),dcreatesystime,120)<='2019-10-31' union select '300宿迁科思' as 公司,'1销售订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006') and CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'1销售订单' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006')and CONVERT(varchar(10),dcreatesystime,120)<='2019-10-31' union select '400宿迁杰科' as 公司,'1销售订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006') and CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'1销售订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006')and CONVERT(varchar(10),dcreatesystime,120)<='2019-10-31' union select '500圣诺贝' as 公司,'1销售订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006') and CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'1销售订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006')and CONVERT(varchar(10),dcreatesystime,120)<='2019-10-31' union select '600马鞍山科思' as 公司,'1销售订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..SO_SOMain where cCusCode not in ('0001','0002','0003','0004','0005','0006') and CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'2销售发货' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '100科思股份' as 公司,'2销售发货' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'2销售发货' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120)<='2019-10-31' union select '200香港科思' as 公司,'2销售发货' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'2销售发货' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'2销售发货' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'2销售发货' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'2销售发货' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'2销售发货' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '500圣诺贝' as 公司,'2销售发货' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'2销售发货' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'2销售发货' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..DispatchList where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'3销售出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '100科思股份' as 公司,'3销售出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'3销售出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '200香港科思' as 公司,'3销售出库' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'3销售出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'3销售出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'3销售出库' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'3销售出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'3销售出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '500圣诺贝' as 公司,'3销售出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'3销售出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'3销售出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord32 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'4销售开票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '100科思股份' as 公司,'4销售开票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'4销售开票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '200香港科思' as 公司,'4销售开票' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'4销售开票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'4销售开票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'4销售开票' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'4销售开票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'4销售开票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '500圣诺贝' as 公司,'4销售开票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'4销售开票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'4销售开票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..SaleBillVouch where CONVERT(varchar(10),dcreatesystime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'5请购单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120)<='2019-10-31' union select '100科思股份' as 公司,'5请购单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'5请购单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120)<='2019-10-31' union select '200香港科思' as 公司,'5请购单' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'5请购单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120)<='2019-10-31' union select '300宿迁科思' as 公司,'5请购单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'5请购单' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120)<='2019-10-31' union select '400宿迁杰科' as 公司,'5请购单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'5请购单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120)<='2019-10-31' union select '500圣诺贝' as 公司,'5请购单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'5请购单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120)<='2019-10-31' union select '600马鞍山科思' as 公司,'5请购单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..PU_AppVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'6采购订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '100科思股份' as 公司,'6采购订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'6采购订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '200香港科思' as 公司,'6采购订单' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'6采购订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'6采购订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'6采购订单' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'6采购订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'6采购订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '500圣诺贝' as 公司,'6采购订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'6采购订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'6采购订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..po_pomain where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'7采购入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '100科思股份' as 公司,'7采购入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'7采购入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '200香港科思' as 公司,'7采购入库' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'7采购入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'7采购入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'7采购入库' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'7采购入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'7采购入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '500圣诺贝' as 公司,'7采购入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'7采购入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'7采购入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord01 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'8采购发票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '100科思股份' as 公司,'8采购发票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'8采购发票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '200香港科思' as 公司,'8采购发票' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'8采购发票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'8采购发票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'8采购发票' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'8采购发票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'8采购发票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120)<='2019-10-31' union select '500圣诺贝' as 公司,'8采购发票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120)=CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'8采购发票' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120)<='2019-10-31' union select '600马鞍山科思' as 公司,'8采购发票' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..PurBillVouch where CONVERT(varchar(10),cmaketime,120)=CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'9材料出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '100科思股份' as 公司,'9材料出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'9材料出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '200香港科思' as 公司,'9材料出库' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'9材料出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'9材料出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'9材料出库' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'9材料出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'9材料出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '500圣诺贝' as 公司,'9材料出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'9材料出库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'9材料出库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord11 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'9成品入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '100科思股份' as 公司,'9成品入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'9成品入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '200香港科思' as 公司,'9成品入库' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'9成品入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'9成品入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'9成品入库' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'9成品入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'9成品入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '500圣诺贝' as 公司,'9成品入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'9成品入库' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'9成品入库' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..rdrecord10 where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'9形态转换' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '100科思股份' as 公司,'9形态转换' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'9形态转换' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '200香港科思' as 公司,'9形态转换' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'9形态转换' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'9形态转换' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'9形态转换' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'9形态转换' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'9形态转换' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '500圣诺贝' as 公司,'9形态转换' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'9形态转换' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'9形态转换' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..AssemVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'8生产订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..mom_order where CONVERT(varchar(10),CreateDate,120)<='2019-10-31' union select '100科思股份' as 公司,'8生产订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..mom_order where CONVERT(varchar(10),CreateDate ,120)=CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'8生产订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..mom_order where CONVERT(varchar(10),CreateDate ,120)<='2019-10-31' union select '200香港科思' as 公司,'8生产订单' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..mom_order where CONVERT(varchar(10),CreateDate ,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'8生产订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..mom_order where CONVERT(varchar(10),CreateDate ,120)<='2019-10-31' union select '300宿迁科思' as 公司,'8生产订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..mom_order where CONVERT(varchar(10),CreateDate ,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'8生产订单' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..mom_order where CONVERT(varchar(10),CreateDate ,120)<='2019-10-31' union select '400宿迁杰科' as 公司,'8生产订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..mom_order where CONVERT(varchar(10),CreateDate ,120) =CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'8生产订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..mom_order where CONVERT(varchar(10),CreateDate ,120)<='2019-10-31' union select '500圣诺贝' as 公司,'8生产订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..mom_order where CONVERT(varchar(10),CreateDate ,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'8生产订单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..mom_order where CONVERT(varchar(10),CreateDate ,120)<='2019-10-31' union select '600马鞍山科思' as 公司,'8生产订单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..mom_order where CONVERT(varchar(10),CreateDate ,120) =CONVERT(varchar(10),GETDATE(),120) union select '100科思股份' as 公司,'9调拨单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '100科思股份' as 公司,'9调拨单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_100_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '200香港科思' as 公司,'9调拨单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '200香港科思' as 公司,'9调拨单' as 单据类型, '当天合计'as 时间,count(*) 单据数量 from UFDATA_200_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '300宿迁科思' as 公司,'9调拨单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '300宿迁科思' as 公司,'9调拨单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_300_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '400宿迁杰科' as 公司,'9调拨单' as 单据类型, '本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '400宿迁杰科' as 公司,'9调拨单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120)=CONVERT(varchar(10),GETDATE(),120) union select '500圣诺贝' as 公司,'9调拨单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120)<='2019-10-31' union select '500圣诺贝' as 公司,'9调拨单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_500_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120) union select '600马鞍山科思' as 公司,'9调拨单' as 单据类型,'本月合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) <='2019-10-31' union select '600马鞍山科思' as 公司,'9调拨单' as 单据类型,'当天合计'as 时间,count(*) 单据数量 from UFDATA_400_2019..TransVouch where CONVERT(varchar(10),dnmaketime,120) =CONVERT(varchar(10),GETDATE(),120)", conn);
                    conn.Open();
                    SqlDataAdapter da = new SqlDataAdapter();
                    da.SelectCommand = cmd;
                    DataSet ds = new DataSet();
                    da.Fill(ds);
                    conn.Close();
                    //以下是声明并创建excel文件 
                    Microsoft.Office.Interop.Excel.Application xlApp;
                    Microsoft.Office.Interop.Excel.Workbook xlWorkBook;
                    Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;
                    object misValue = System.Reflection.Missing.Value;
                    xlApp = new Microsoft.Office.Interop.Excel.Application();
                    xlWorkBook = xlApp.Workbooks.Add(misValue);
                    xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                    int i = 0;
                    int j = 0;
                    string data = null; //初始化结果
                    for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                    {
                        for (j = 0; j <= ds.Tables[0].Columns.Count - 1; j++)
                        {
                            data = ds.Tables[0].Rows[i].ItemArray[j].ToString();
                            xlWorkSheet.Cells[i + 1, j + 1] = data;
                        }
                    }
                    //数据导入到excel文件
                    string fname2 = "d:\\";
                    string fname1 = "订单统计情况" + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                    string FileName = fname2 + fname1 + ".xls";
                    xlWorkBook.SaveAs(FileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                    xlWorkBook.Close(true, misValue, misValue);
                    xlApp.Quit();
                    GC.Collect();//强行销毁   
                    //MessageBox.Show("生成文件成功!");
                    string user = ConfigurationManager.AppSettings["user"];
                    string password = ConfigurationManager.AppSettings["password"];
                    string mailAddress = ConfigurationManager.AppSettings["mail"];
                    string host = ConfigurationManager.AppSettings["smtpserver"];
                    string ToAddress = ConfigurationManager.AppSettings["Toadd"]; ;//目标邮件地址。
 
                                                         //message.To.Add(receiver);//收件人
                                                         //message.CC.Add(sender);//抄送人
                                                         //初始化SMTP类
                    SmtpClient smtp = new SmtpClient(host);
                    smtp.EnableSsl = true; //开启安全连接。
                    smtp.Credentials = new NetworkCredential(user, password); //创建用户凭证
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network; //使用网络传送
                    MailMessage message = new MailMessage(mailAddress, ToAddress, "ERP系统运行统计情况", "各位好！附件中为今日系统内各业务单据运行统计情况，请查收！"); //创建邮件
                    string fileAddress = fname2 + fname1 + ".xls";   //@"D:\test.txt";
                    string MIME = MimeMapping.GetMimeMapping(fileAddress);//文件的MediaType MIME 
                                                                          //message.AlternateViews.Add(new AlternateView(fileAddress,MIME)); //发送附加内容（附加的内容为文件中的内容）
                                                                          //发送附加件
                    message.Attachments.Add(new Attachment(fileAddress, MIME));
                    smtp.Send(message); //发送邮件
                    //MessageBox.Show("发送成功");
                }
                catch (Exception e1)
                {
                MessageBox.Show("发送失败：" + e1);
                throw;
                }
            Console.WriteLine("sende_mail_OK, event fired at: " + DateTime.Now.ToString());

        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new DataSource();
            childForm.MdiParent = this;
            //childForm.Text = Index;
            childForm.Show();
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
            log.Info("exit system!");
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }
        private void Timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = System.DateTime.Now;
            toolStripStatusLabel1.Text = dt.ToString();//实时显示时间
            
        }

        private void FileMenu_Click(object sender, EventArgs e)
        {

        }

        private void ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            Form childForm = new MailConfig();
            childForm.MdiParent = this;
            childForm.Show();
        }

        private void ToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            Form childForm = new MainForm();
            childForm.MdiParent = this;
            childForm.Show();
        }

        private void MDIParent_SizeChanged(object sender, MouseEventArgs e)
        {
            if (WindowState == FormWindowState.Minimized)
            {
                this.Hide();
                this.notifyIcon1.Visible = true;
                this.notifyIcon1.ShowBalloonTip(30, "注意", "关闭本程序将不能发送统计邮件！", ToolTipIcon.Info);
            }
        }

        private void ToolStripStatusLabel3_Click(object sender, EventArgs e)
        {
        }

        private void ToolStripMenuItem3_Click(object sender, EventArgs e)
        {
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Enabled = false;
            timer.Stop();
            toolStripStatusLabel3.Text = "服务关闭！";
            log.Info("stop server!");
        }

        private void ToolStripMenuItem4_Click(object sender, EventArgs e)
        {
            System.Timers.Timer timer = new System.Timers.Timer();
            timer.Enabled = true;
            timer.Start();
            toolStripStatusLabel3.Text = "服务启动！";
            log.Info(" start server！");
        }

        private void AboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form childForm = new AboutBox();
            childForm.MdiParent = this;
            childForm.Show();
        }

        private void MDIParent_Load(object sender, EventArgs e)
        {

        }
    }
}
